<?php
defined('IN_IA') or exit('Access Denied');
use Plug\Plug;
use Pub\tool\Develop;
use Pub\tool\Setting;
use Pub\tool\Tool;
use Pub\tool\Setting as SettingCache;
global $_GPC,$_W;

if($_W['container'] != 'wechat' || $_W['os'] != 'mobile'){
    message('本系统仅支持在手机端微信打开','','info');
    exit;
}

checkauth();


require MODULE_ROOT.'/vendor/autoload.php';

//防封链接跳转代码
if(SettingCache::get(SettingCache::DEFEND) && !isset($_GPC["defend_jump"])){
    $Plug = new Plug(Plug::DEFEND);
    if($Plug->check()){
        $_domain = $Plug->get()->getDomain();
        header("Location:".$_domain["url"]);
        exit;
    }
}


$_web_name = Setting::get(Setting::WEB_NAME);
//Sscript
//分享share_id
$_share_id = '';
if(isset($_GPC['share_id']) && $_GPC['share_id']) $_share_id = $_GPC['share_id'];
$_script = "
<script>
    window.sysinfo = {
        url:'".$this->createMobileUrl('api')."',
        attach_url:'".$_W['attachurl']."',
        web_name:'".$_web_name."', 
        share_id:'".$_share_id."'
        ";
$_script .= "}</script>";
$_script .= "<script src='https://webapi.amap.com/maps?v=1.4.15&key=".SettingCache::get(SettingCache::MAP_KEY)."&plugin=AMap.Geolocation,AMap.Geocoder'></script>";
if(KUYUAN_DEBUG){
    $Develop = new Develop();
    $_script .= $Develop->script();
}else{
    $_script .= Tool::script();
}
//Escript
include $this->template('index');